<!DOCTYPE html>
<html >
<head>
	<meta charset="UTF-8">
	<link rel="stylesheet" type="text/css" href="css/style.css" />
	<script type="text/javascript" src="js/index.js"></script>
	<title>动物管理系统</title>
</head>
<body>
	<h1>动物管理系统</h1>
	<table>
		<?php
		require_once('./server/conn.php');
		$sql = "select * from result";
		$result = $conn->query($sql);
		if ($result->num_rows >0){
			while($row = $result->fetch_assoc()){
		?>
				<tr>
					<td><?php echo $row['id'] ?></td>
					<td><?php echo $row['name'] ?></td>
					<td><?php echo $row['ks'] ?></td>
					<td><?php echo $row['pz'] ?></td>
					<td><?php echo $row['sfzx'] ?></td>
					<td>
						<button onclick="toUpdate(this)">修改</button>
						<button onclick="remove(this)">删除</button>
					</td>
				</tr>
		<?php		
			}
		}
			$conn->close();
		?>
		<tr>
			<td colspan="6">
				<a href="insert.php"><button>添加</button></a>
			</td>
		</tr>
	</table>
	<script type="text/javascript">
		function remove(ele){
			let id = ele.parentElement.parentElement.children[0].innerText;
			window.location.href="./server/remove_server.php?id=" + id;
		}
		function toUpdate(ele){
			let id = ele.parentElement.parentElement.children[0].innerText;
			window.location.href = "./update.php?id=" + id;
		}
	</script>
</body>
</html>
